package com.nbsaas.boot.contoller;

import com.nbsaas.boot.rest.annotations.AddOperator;
import com.nbsaas.boot.rest.annotations.DeleteOperator;
import com.nbsaas.boot.rest.annotations.UpdateOperator;
import com.nbsaas.boot.rest.annotations.ViewOperator;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import com.nbsaas.boot.rest.annotations.CreateData;
import com.nbsaas.boot.rest.annotations.UpdateData;
import com.nbsaas.boot.app.api.domain.request.AppRoleMenuRequest;
import com.nbsaas.boot.app.api.domain.request.AppRoleMenuSearch;
import com.nbsaas.boot.app.api.domain.response.AppRoleMenuResponse;
import com.nbsaas.boot.app.api.domain.simple.AppRoleMenuSimple;
import com.nbsaas.boot.app.api.apis.AppRoleMenuApi;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
*  对外控制器
*/
@RequiresAuthentication
@RestController
@RequestMapping("/appRoleMenu")
public class AppRoleMenuController {


    @Resource
    private AppRoleMenuApi appRoleMenuApi;


    @RequiresPermissions("appRoleMenu")
    @RequestMapping("/search")
    public PageResponse <AppRoleMenuSimple> search(AppRoleMenuSearch request) {
        return appRoleMenuApi.search(request);
    }

    @RequiresPermissions("appRoleMenu")
    @RequestMapping("/list")
    public ListResponse<AppRoleMenuSimple> list(AppRoleMenuSearch request) {
        return appRoleMenuApi.list(request);
    }

    /**
    * 添加数据
    *
    * @param request
    * @return
    */
    @RequiresPermissions("appRoleMenu")
    @CreateData
    @RequestMapping("/create")
    public ResponseObject <AppRoleMenuResponse> create(@Validated(AddOperator.class) AppRoleMenuRequest request) {
        return appRoleMenuApi.create(request);
    }

   @RequiresPermissions("appRoleMenu")
   @UpdateData
   @RequestMapping("/update")
   public ResponseObject<AppRoleMenuResponse> update(@Validated(UpdateOperator.class) AppRoleMenuRequest request) {
       return appRoleMenuApi.update(request);
   }

    @RequiresPermissions("appRoleMenu")
    @RequestMapping("/delete")
    public ResponseObject<?> delete(@Validated(DeleteOperator.class) AppRoleMenuRequest request) {
        return appRoleMenuApi.delete(request);
    }

    @RequiresPermissions("appRoleMenu")
    @RequestMapping("/view")
    public ResponseObject <AppRoleMenuResponse> view(@Validated(ViewOperator.class) AppRoleMenuRequest  request) {
        return appRoleMenuApi.view(request);
    }
}